Trouble adding link to Link Module in DXL

I've written a script that is supposed to link each object of type "Requirement" to its parent.  However, I am currently getting an error saying: null Object parameter was passed into argument position 2.  Here is the code I've created:

Filter f = attribute "*Object Type" == "Requirement";
set f;
for o in (current Module) do {
    oParent = parent(o);
    o->"Requirement Links"->oParent;
}
filtering off;

The problem occurs on the 2nd line within the for-loop.  I've made sure that there is a linkset set up between the current module and the link module "Requirement Links", so I don't understand why I'm getting a problem.

 

Chris


chrscote - Wed Oct 31 15:06:56 EDT 2018

Re: Trouble adding link to Link Module in DXL
PekkaMakinen - Thu Nov 01 02:06:37 EDT 2018

Level 1 objects do not have any parent objects, so parent(o) is null. You should always check for null results:

if (!null parent(o)) oParent = parent(o)

Re: Trouble adding link to Link Module in DXL
chrscote - Thu Nov 01 11:22:04 EDT 2018

PekkaMakinen - Thu Nov 01 02:06:37 EDT 2018

Level 1 objects do not have any parent objects, so parent(o) is null. You should always check for null results:

if (!null parent(o)) oParent = parent(o)

Ah, of course.  Figures that it would be something simple like that.  Thanks.